
#include <string.h>
 #include <stdlib.h>
#include "message.h"
#include "main.h"
#include "version.h"
#include "type.h"

//MI_CHAR *gVersionDate  = __DATE__;
//MI_CHAR *gVersionTime  = __TIME__;

const MI_CHAR aMonth[12][4] = {
                            {"Jan"},
                            {"Feb"},
                            {"Mar"},
                            {"Apr"},
                            {"May"},
                            {"Jun"},
                            {"Jul"},
                            {"Aug"},
                            {"Sept"},
                            {"Oct"},
                            {"Nov"},
                            {"Dec"},
                        };

const MI_CHAR bMonth[12][4] = {
                            {"01"},
                            {"02"},
                            {"03"},
                            {"04"},
                            {"05"},
                            {"06"},
                            {"07"},
                            {"08"},
                            {"09"},
                            {"10"},
                            {"11"},
                            {"12"},
                        };   


MI_BOOL convert_data_time(MI_U32 *date,MI_U32 *time)   
{
    MI_CHAR now_date[12] = {0};
    MI_CHAR now_time[12] = {0};

    MI_CHAR year[4] = {0};
    MI_CHAR month[4] = {0};
    MI_CHAR day[4] = {0};
    MI_CHAR now_month[4] = {0};

    MI_CHAR hour[4] = {0};
    MI_CHAR sec[4] = {0};
    MI_CHAR mil[4] = {0};
    const MI_CHAR  *p = APPCATION_VERSION_TIME;

    memcpy(now_time,APPCATION_VERSION_TIME,strlen(APPCATION_VERSION_TIME));
    sscanf(APPCATION_VERSION_DATE,"%s %s %s",month,day,year);
    memcpy(hour,p,2);
    memcpy(sec,p+3,2);
    memcpy(mil,p+6,2);

    for (int i=0;i<12;i++)
    {
        if (strcmp(aMonth[i],month) == 0)
        {
            memcpy(now_month,bMonth[i],strlen(bMonth[i]));
            break;
        }
    }
    memset(now_time,0,sizeof(now_time));
    sprintf(now_date,"%s%s%s",year,now_month,day);
    sprintf(now_time,"%s%s%s",hour,sec,mil);

    //printf("Now Date %s\r\n",now_date);
    //printf("Now Time %s\r\n",now_time);

    *date = atoi(now_date);
    *time = atoi(now_time);

    return MI_TRUE;
}                     